home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / imagemap / imap_misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-05  |  3.4 KB  |  116 lines

  1. /*
  2.  * This is a plug-in for the GIMP.
  3.  *
  4.  * Generates clickable image maps.
  5.  *
  6.  * Copyright (C) 1998-1999 Maurits Rijk  lpeek.mrijk@consunet.nl
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  *
  22.  */
  23.  
  24. #include "imap_main.h"
  25. #include "imap_misc.h"
  26.  
  27. GtkWidget*
  28. make_toolbar_icon(GtkWidget *toolbar, GtkWidget *window, char **data, 
  29.           const char *identifier, const char *tooltip, 
  30.           void (*callback)(GtkWidget*, gpointer), gpointer udata)
  31. {
  32.    GtkWidget *iconw;
  33.    GdkPixmap *icon;
  34.    GdkBitmap *mask;
  35.    GtkStyle  *style;
  36.  
  37.    style = gtk_widget_get_style(window);
  38.    icon = gdk_pixmap_create_from_xpm_d(window->window, &mask,
  39.                        &style->bg[GTK_STATE_NORMAL], 
  40.                        data);
  41.    iconw = gtk_pixmap_new(icon, mask);
  42.    return gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
  43.                   identifier, tooltip, NULL, iconw,
  44.                   GTK_SIGNAL_FUNC(callback), udata);
  45. }
  46.  
  47. GtkWidget*
  48. make_toolbar_radio_icon(GtkWidget *toolbar, GtkWidget *window, 
  49.              GtkWidget *prev, char **data, 
  50.              const char *identifier, const char *tooltip, 
  51.              void (*callback)(GtkWidget*, gpointer),
  52.              gpointer udata)
  53. {
  54.    GtkWidget *iconw;
  55.    GdkPixmap *icon;
  56.    GdkBitmap *mask;
  57.    GtkStyle  *style;
  58.  
  59.    style = gtk_widget_get_style(window);
  60.    icon = gdk_pixmap_create_from_xpm_d(window->window, &mask,
  61.                        &style->bg[GTK_STATE_NORMAL], 
  62.                        data);
  63.    iconw = gtk_pixmap_new(icon, mask);
  64.    return gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
  65.                      GTK_TOOLBAR_CHILD_RADIOBUTTON, prev,
  66.                      identifier, tooltip, NULL, iconw,
  67.                      GTK_SIGNAL_FUNC(callback), udata);
  68. }
  69.  
  70. GtkWidget*
  71. make_toolbar_toggle_icon(GtkWidget *toolbar, GtkWidget *window, 
  72.              char **data, const char *identifier, 
  73.              const char *tooltip, 
  74.              void (*callback)(GtkWidget*, gpointer),
  75.              gpointer udata)
  76. {
  77.    GtkWidget *iconw;
  78.    GdkPixmap *icon;
  79.    GdkBitmap *mask;
  80.    GtkStyle  *style;
  81.  
  82.    style = gtk_widget_get_style(window);
  83.    icon = gdk_pixmap_create_from_xpm_d(window->window, &mask,
  84.                        &style->bg[GTK_STATE_NORMAL], 
  85.                        data);
  86.    iconw = gtk_pixmap_new(icon, mask);
  87.    return gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
  88.                      GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
  89.                      identifier, tooltip, NULL, iconw,
  90.                      GTK_SIGNAL_FUNC(callback), udata);
  91. }
  92.  
  93. #define SASH_SIZE 8
  94.  
  95. static gint _sash_size = SASH_SIZE;
  96.  
  97. void
  98. set_sash_size(gboolean double_size)
  99. {
  100.    _sash_size = (double_size) ? 2 * SASH_SIZE : SASH_SIZE;
  101. }
  102.  
  103. void
  104. draw_sash(GdkWindow *window, GdkGC *gc, gint x, gint y)
  105. {
  106.    draw_rectangle(window, gc, TRUE, x - _sash_size / 2, y - _sash_size / 2, 
  107.           _sash_size, _sash_size);
  108. }
  109.  
  110. gboolean
  111. near_sash(gint sash_x, gint sash_y, gint x, gint y)
  112. {
  113.    return x >= sash_x - _sash_size / 2 && x <= sash_x + _sash_size / 2 &&
  114.       y >= sash_y - _sash_size / 2 && y <= sash_y + _sash_size / 2;
  115. }
  116.